<!-- MyAccumulatePoints_Frame.html -->
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
		<title>我的积分frame</title>
		<link rel="stylesheet" href="../../css/mui.min.css"/>
		<link rel="stylesheet" href="../../css/CFNetPP_Base.css">
		<style type="text/css">
			html,body{
				background-color: white;
			}
			.loadFailure {
				left: 0;
				top: 0;
				margin: 0 auto;
				text-align: center;
				padding: 40px 20px;
				width: 100%;
			}
			.loadFailure img {
				max-width: 100%;
				display: inline-block;
			}
			.noSign {
				left: 0;
				top: 0;
				margin: 0 auto;
				text-align: center;
				padding: 40px 20px;
				width: 100%;
            }
			.noSign img {
				max-width: 100%;
				display: inline-block;
			}
			.top-tag-div{
				text-align: right;
				color: #18b4ed;
				font-size: 14px;
				padding: 10px;
			}
			.question-icon{
				width: 16px;
				position: relative;
				top: 2px;
			}
			.top-content-div{
				text-align: center;
			}
			.round-div{
				width: 100px;
				height: 100px;
				border-radius: 50px;
				background-color: #18b4ed;
				margin:0 auto;
			}
			.top-title{
				padding-top: 20px;
				font-size: 14px;
				color: #ddd;
				margin: 0;
			}
			.top-a-p-num{
				font-size: 20px;
				color: white;
				margin: 0;
				margin-top: 10px;
			}
			.top-bottom-div{
				text-align: center;
				padding: 0 10px;
				height: 12px;
			}
			.top-bottom-a-p-span{
				font-size: 12px;
				color: #999;
				line-height: 12px;
				width: 80px;
				background-color: white;
				position: relative;
				top: -14px;
			}
			.line-div{
				height: 1px;
				width: 100%;
				border-top: 1px solid #dedede;
				-webkit-transform: scaleY(.5);
			    transform: scaleY(.5);
			    margin-top: 30px;
			}
			.list-div{
				padding: 0 10px;
			}
			.right-span{
				font-size: 14px;
				color: #18b4ed;
				line-height: 60px;
			}
			.content-left-div{
				margin-right: 60px;
				padding: 10px 0;
			}
			.content-right-div{
				width: 60px;
				height: 60px;
				float: right;
				text-align: right;
			}
			.content-title{
				font-size: 14px;
				color: #333;
				line-height: 20px;
			}
			.content-time{
				font-size: 12px;
				color: #666;
				line-height: 20px;
			}
			.a-p-cell{
				padding: 0;
			}
		</style>
	</head>
	<body>
		<div class="top-div" id="top_div">
			<div class="top-tag-div">
				<!--<img class="question-icon" src="../../image/icon_question.png">
				积分规则-->
			</div>
			<div class="top-content-div">
				<div class="round-div">
					<p class="top-title">
						积分
					</p>
					<p class="top-a-p-num" id="all_num">
						<!--234-->
					</p>
				</div>
			</div>
			<div class="top-bottom-div">
				<div class="line-div"></div>
				<span class="top-bottom-a-p-span">
					积分明细
				</span>
			</div>
		</div>
		<div class="list-div">
			<ul id="AccmulatePointsTableView" class="mui-table-view">
			<!--	<li class="mui-table-view-cell a-p-cell">
					<div class="content-right-div">
						<span class="right-span">
							+3
						</span>
					</div>
					<div class="content-left-div">
						<p class="content-title">
							学习互动资源
						</p>
						<p class="content-time">
							2017-11-21 07 : 54
						</p>
					</div>
				</li>-->
			</ul>
			
		
		</div>
			<div class="noSign" hidden="hidden" id="noData">
			<img src="../../image/icon_no_data.png" width="60%">
			<p class="font16 top_15 base_dark_grey" >
				暂无数据
			</p>
		</div>
		<div class="loadFailure" hidden="hidden" id="noNet">
			<img src="../../image/icon_img01.png" width="60%">
			<p class="" >
				数据加载失败
			</p>
			<p>
				请检查您的网络
			</p>
			<button type="button" class="mui-btn mui-btn-outlined" onclick="refreshData()">
				重新加载
			</button>
		</div>
			
	</body>
	<script type="text/javascript" src="../../script/jquery.min.js"></script>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/MD5.js"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>
	<script type="text/javascript" src="../../script/common.js"></script>
	<script type="text/javascript" src="../../script/AccumulatePoints.js"></script>
	<script type="text/javascript">
		var page=1;
		var row=10;
		var refreshCount=0;
		apiready = function() {
		 //开启加载框
		  showProgress();
		  getUserAllPointsData();
		  loadNewData();
		  setRefreshHeader();
		  setPullUpRefresh();
		}
		//刷新数据
		function refreshData() {
			$('#noNet').hide();
			showProgress();
			loadNewData();
		}
		//获得新数据
		function loadNewData() {
			page = 1;
			loadData();
		}
        //获得更多数据
		function loadMoreData() {
			page++;
			loadData();
		}	
		
		
		//获取用户总积分
		function getUserAllPointsData(){
			var param = {
				jid : $api.getStorage('cfnetppjxid'),
				uid: $api.getStorage('cfnetppuid'),
				sjid : $api.getStorage('cfnetppjid'),//实习 jid
			};
		   
			cfnetppPOST(url_getUserAllPoints, param, false, function(data, status) {
				if (status == 'success') {
					$('#noNet').hide();
					if (data.code == 200) {
						$('#all_num').html(data.point);
						$('#top_div').show();
					} else {
						$('#top_div').hide();
					}
				} else {
					
				}
			});
		}
		
		
		//从网路获取数据
		function loadData() {
			var param = {
				jid : $api.getStorage('cfnetppjxid'),
				uid: $api.getStorage('cfnetppuid'),
				sjid : $api.getStorage('cfnetppjid'),//实习 jid
				page : page,
				rows : row,
			};
		   
			cfnetppPOST(url_getPointsDetails, param, false, function(data, status) {
			
				hideProgress();
				api.refreshHeaderLoadDone();
				if (status == 'success') {
					$('#noNet').hide();
					if (data.code == 200) {
						$('#noData').hide();
						
						var list = data.data;
						if (list != null &&  list.length > 0) {
						   
							SetUI(list)
							refreshCount = list.length;
						} else {
							if (page == 1) {
								$('#AccmulatePointsTableView').html('');
								$('#noData').show();
								$('#noNet').hide();
						    } else {
							   api.refreshHeaderLoadDone();
							    ShowToast('我是有底线的')
								$('#noData').hide();
								$('#noNet').hide();
						    }
						}
					} else {
						if (page == 1) {
							$('#AccmulatePointsTableView').html('');
							$('#noData').show();
							$('#noNet').hide();
						} else {
						   api.refreshHeaderLoadDone();
						    ShowToast('我是有底线的')
							$('#noData').hide();
							$('#noNet').hide();
						}
					}
				} else {
					$('#noNet').show();
				}
			});
		}
	

		//显示在html
		function SetUI(list) {
			var len = list.length;
			var strhtml="";
			var data = "";
			
			for (var i = 0; i < list.length; i++) {
				data = list[i];
//				var DataArr = JSON.stringify(data).replace(/"/g, '&quot;');
                var str='<li class="mui-table-view-cell a-p-cell">'+
					'<div class="content-right-div">'+
						'<span class="right-span">'+
							judgePointsPositiveAndnegative(returnInt(data.points))+
						'</span>'+
					'</div>'+
					'<div class="content-left-div">'+
						'<p class="content-title">'+
							isString(data.alias)+
						'</p>'+
						'<p class="content-time">'+
							getTimeHMS((data.instime)*1000)+
						'</p>'+
					'</div>'+
				'</li>';
				
				strhtml = strhtml + str;
			}
			if (page == 1) {
				$('#AccmulatePointsTableView').html(strhtml);
			} else {
				$('#AccmulatePointsTableView').append(strhtml);
			}
		}
		//打开积分规则页
		function openRule(){
			api.openWin({useWKWebView:true,
		        name: 'IntegralRule_Win',
		        url: 'IntegralRule_Win.html'
	        });
		}
		
	</script>
</html>